<template>
  <div id="workbench" @click="login">
    <div class="user-info back-image">
      <div class="avatar">
        <img :src="imageUrl"></img>
      </div>
      <div class="name-time">
        <p>
          <span class="name">注册/登录</span>
          <span class="area"></span>
        </p>
      </div>
      <div class="wallet" v-show="selfSupport"><i class="iconfont icon-qianbao"></i> 钱包</div>
    </div>
    <div class="data-count">
      <div class="count-type" v-for="(item, index) in dataType" :key="item.value">
        <div>
          <p class="tip">总数-- </p>
          <p class="value">
            <span class="num">
              --
            </span>
            <span class="text">今日新增</span>
          </p>
          <p class="name">
            <span>{{ item.name }}</span>
            <van-icon name="info" :color="item.select ? '#007AE6' : '#CED1D6' " />
          </p>
        </div>
      </div>
    </div>
    <div class="my-workbench">
      <div class="title">我的工作台</div>
      <ul class="moduleList">
        <li class="module" v-for="(item, index) in moduleList" :key="index"
        :class="item.class">
          <div class="box-center">
            <span class="back-image icon-box">
              <svg class="icon-svg" aria-hidden="true">
                <use :xlink:href="`#icon-${item.icon}`"></use>
              </svg>
            </span>
            <span class="name">{{ item.name }}</span>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
const imageUrl = require('IMG/custom/placeholder-header-img.png')
const backImage = require('IMG/dynamics/backImage.png')
const titleImage = require('IMG/dynamics/title.png')
const dataType = [
  { trend: 0, value: 'shareTimesDataVo', todayCount: 0, totalCount: 0, yesterdayCount: 0, select: false, name: '分享次数', href: '/dynamics/articleShareList' },
  { trend: 0, value: 'customerScanArticleDataVo', query: 'articleCustomerDataVo', todayCount: 0, totalCount: 0, yesterdayCount: 0, select: false, name: '文章浏览量', href: '/dynamics/browse' },
  { trend: 0, value: 'strangerDataVo', query: 'strangerDataVo', todayCount: 0, totalCount: 0, yesterdayCount: 0, select: false, name: '访客总数', href: '/dynamics/thread' },
  { trend: 0, value: 'customerDataVo', query: 'customerDataVo', todayCount: 0, totalCount: 0, yesterdayCount: 0, select: false, name: '意向客户', href: '/custom/classify?type=2' },
  { trend: 0, value: 'customerWithMobileDataVo', query: 'customerWithMobileDataVo',  todayCount: 0, totalCount: 0, yesterdayCount: 0, select: false, name: '留电客户', href: '/custom/classify?type=3' },
  { trend: 0, value: 'communicateCustomerTimesDataVo', query: 'communicateCustomerDataVo', todayCount: 0, totalCount: 0, yesterdayCount: 0, select: false, name: '互动数量', href: '/dynamics/interact' }
]
const moduleList = [
  { imageUrl: require("@/assets/img/dynamics/building.png"), class: "box-shadow-1px-bottom-right", icon: 'shouye_loupan', name: '楼盘', href: '/market', id: 'loupan' },
  { imageUrl: require("@/assets/img/dynamics/write.png"), class: "box-shadow-1px-bottom-right", icon: 'shouye_xieyixie', name: '写一写', href: '/discover/newlyAdded' },
  { imageUrl: require("@/assets/img/dynamics/card.png"), class: "box-shadow-1px-bottom", icon: 'shouye_mingpian', name: '名片', href: '/user/share-card' },
  { imageUrl: require("@/assets/img/dynamics/custom.png"), class: "box-shadow-1px-bottom-right", icon: 'shouye_kehu', name: '客户', href: '/custom' },
  { imageUrl: require("@/assets/img/dynamics/dynamic.png"), class: "box-shadow-1px-bottom-right", icon: 'shouye_dongtai', value: 'unreadDynamicCount', name: '动态', href: '/dynamics/activityTrack' },
  { imageUrl: require("@/assets/img/dynamics/news.png"), class: "box-shadow-1px-bottom", icon: 'shouye-xiaoxi', value: 'unreadMessageCount', name: '消息', href: '/dynamics/message/messageList' },
  { imageUrl: require("@/assets/img/dynamics/date.png"), class: "box-shadow-1px-right", icon: 'shouye-shuju', name: '数据', href: '/dynamics/dataCount' },
  { imageUrl: require("@/assets/img/dynamics/invite.png"), class: "box-shadow-1px-right", icon: 'shouye_yaoqing', name: '邀请', href: '/user/invitation/awWelfare' },
  { imageUrl: require("@/assets/img/dynamics/my.png"), class: "", icon: 'shouye_wode', name: '我的', href: '/user' }
]
export default {
  data() {
    return {
      dataType,
      imageUrl,
      backImage,
      titleImage,
      moduleList,
      selfSupport: ''
    }
  },
  created() {
    // 未登录状态默认为1，显示推广有礼标识
    this.selfSupport =  localStorage.getItem('selfSupport')
  },
  methods:{
    login() {
      this.$router.push('/wx/login')
    }
  },
  mounted() {
    wx.hideOptionMenu()
  }
}
</script>

<style lang="less" scoped>
.user-info {
  width: 100%;
  height: 124px;
  background: #0062AC;
  display: flex;
  // justify-content: space-between;
  align-items: center;
  padding: 0 0 0 24px;
  .name-time {
    color: #fff;
    padding-left: 16px;
    font-size: 0;
    flex: 1;
    .name {
      font-size: 26px;
      height: 32px;
      line-height: 32px;
      font-weight: bold;
      max-width: 200px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      display: inline-block;
      // float: left;
      vertical-align: text-bottom;
    }
    
    .name-8 {
      font-size: 20px;
    }
    .area {
      font-size: 12px;
      height: 18px;
      line-height: 18px;
      padding-left: 5px;
      display: inline-block;
      margin-bottom: 2px;
      // border-bottom: 1px solid transparent;
      vertical-align: text-bottom;
    }
    .time {
      display: block;
      font-size: 12px;
      height: 22px;
      line-height: 22px;
      padding-top: 3px;
      // font-weight: 200;
    }
  }
  .avatar {
    width: 60px;
    height: 60px;
    img {
      border-radius: 50%;
      border: 2px solid #fff;
    }
  }
  .wallet{
    font-size: 12px;
    color:rgba(64,81,112,1);
    width: 66px;
    height: 36px;
    background-color: #fff;
    border-top-left-radius: 19px;
    border-bottom-left-radius: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    i{
      color: #E4AF67;
      margin-right: 2px;
      font-size: 20px;
    }
  }
}
.data-count {
  padding-bottom: 20px;
  border-bottom: 12px solid #F2F6F7;
  .flexd-tip {
    max-width: 250px;
    padding: 8px 20px 8px 10px;
    border-radius: 8px;
    position: fixed;
    left: 75px;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1;
    font-size: 12px;
    line-height: 20px;
    color: #fff;
    .clear-icon {
      width: 12px;
      height: 12px;
      display: inline-block;
      position: absolute;
      top: 2px;
      right: 3px;
      &:active, &:hover {
        color: #E65E2E;
      }
    }
  }
  .left {
    padding-left: 24px;
  }
  .center{
    justify-content: center;
  }
  .right {
    padding-right: 24px;
    justify-content: flex-end;
  }
  .count-type {
    width: 33.3%;
    margin-top: 24px;
    padding-left: 16px;
    display: inline-flex;
    height: 68px;
    .tip {
      // height: 12px;
      font-size: 10px;
      // line-height: 12px;
      color: #9CA5B5;
    }
    .name {
      font-size: 12px;
      color: #405170;
      padding-top: 4px;
      height: 20px;
      span {
        font-weight: bold;
      }
      i {
        padding-left: 4px;
        vertical-align: top;
      }
    }
    .color-0 {
      color: #405170;
    }
    .color-2 {
      color: #28B324;
    }
    .color-1 {
      color: #E65E2E;
    }
    .value {
      height: 32px;
      line-height: 32px;
      font-size: 0;
      .num {
        font-size: 22px;
      }
      .num-26 {
        font-size: 26px;
      }
      .text {
        color: #9BA4B4;
        font-size: 10px;
        margin-left: -6px;
      }
      .icon-trend {
        i {
          font-size: 10px;
          padding-left: 4px;
        }
      }
    }
  }
}

.back-image {
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

.my-workbench {
  .title {
    color: #13284D;
    height: 26px;
    font-size: 18px;
    font-weight: bold;
    line-height: 26px;
    margin: 16px 0 4px 24px;
  }
  .title-image {
    height: 58px;
    width: 248px;
    margin: 0 auto;
    margin-top: 8px;
  }
  .moduleList {
    padding: 8px 16px;
    padding-top: 4px;
    .module {
      width: 33.3%;
      height: 114px;
      display: inline-flex;
      justify-content: center;
      align-items: center;
      overflow: hidden;
      // margin-right: 1px;
      // margin-bottom: 1px;
      .box-center {
        text-align: center;
        position: relative;
        font-size: 0px;
        .message {
          transform: scale(0.9);
          position: absolute;
          top: -5px;
          right: -3px;
        }
        .icon-box {
          width: 32px;
          height: 32px;
          display: block;
          margin: 0 auto;
        }
        .w-40 {
          width: 40px;
          height: 40px;
        }
        .name {
          color: #333;
          font-size: 0.32rem;
          margin-top: 8px;
          display: inline-block;
          line-height: 16px;
          font-size: 12px;
        }
      }
      &:active {
        background: #eee;
      }
    }
  }
  .icon-svg {
    width: 32px; height: 32px;
    // vertical-align: -0.15em;
    fill: currentColor;
    overflow: hidden;
  }
}

</style>

<style lang="less">
.company-approve-failure.van-dialog{
  .van-dialog__header{
    font-size:18px;
    font-weight:600;
    color:rgba(234,77,46,1);
  }
}
</style>